﻿using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace DataBaseAccessLib
{
    public class Logger
    {
        public static readonly log4net.ILog loginfo = log4net.LogManager.GetLogger("loginfo");//信息日志对象
        public static readonly log4net.ILog logerror = log4net.LogManager.GetLogger("logerror");//错误日志对象
        // private static object lockHelper = new object();
        // private static Logger logger = null;

        private Logger()
        { }


        //初始化设置
        public static void SetConfig()
        {
            log4net.Config.DOMConfigurator.Configure();
        }

        //初始化设置
        public static void SetConfig(FileInfo configFile)
        {
            log4net.Config.DOMConfigurator.Configure(configFile);
        }

        /// <summary>
        /// 写信息日志
        /// </summary>
        /// <param name="info"></param>
        public static void WriteLog(string info)
        {
            if (loginfo.IsInfoEnabled)
            {
                loginfo.Info(info);
            }
        }

        /// <summary>
        /// 写错误日志
        /// </summary>
        /// <param name="info"></param>
        /// <param name="se"></param>
        public static void WriteLog(string info, Exception se)
        {
            if (logerror.IsErrorEnabled)
            {
                logerror.Error(info, se);

            }
        }


    }
}
